# coding=utf-8
import json
import os
import logging


def get_config(run_env=None):
    # 读取配置文件
    config_path = '{}/config.json'.format(os.path.split(os.path.abspath(__file__))[0])
    if os.path.isfile(config_path):
        config_data = open(config_path, "r", encoding="utf-8").read()
        app_config = json.loads(config_data)
        app_config["RUN_ENV"] = run_env

        for k,v in app_config['data_path'].items():
            app_config['data_path'][k] = os.path.split(os.path.abspath(__file__))[0].replace('config', v)

        return app_config
    else:
        logging.error("Config not exist")
        exit()
